package com.changli04._set;

import org.junit.Test;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class hashSetTest {
    @Test
    public void test() {

        Set set = new HashSet();
        set.add("222");
        set.add(1);

        set.add(new Object());
        set.add(new Person("sail",19));
        //需重写 hashCode()方法 才可以体现Set的不可重复性
        set.add(new Person("sail",19));
//        System.out.println(set);

        Iterator it = set.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }
    }



}
